//
//  SettingDataManage.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/19.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "SettingDataManage.h"
#import "API.h"
#import "StringTool.h"
#import "UserModal.h"

@implementation SettingDataManage

-(ResulteMod *)modifypwdWithCustomerId:(NSString *)customerId WithOldPwd:(NSString *)oldPwd WithNewPwd:(NSString *)newPwd;

{
    NSString *url = [NSString stringWithFormat:@"%@",[API urlMake:modifypwd]];
    
    NSString *oldPwdStr = [NSString md5:oldPwd];
    NSString *newStr = [NSString md5:newPwd];
    NSDictionary *dic = @{@"agencyId":customerId,@"oldPwd":oldPwdStr,@"newPwd":newStr,@"reNewPwd":newStr};
     ResulteMod *mod = [Connect doPostOutCaCheWithUrl:url withParamDic:dic];
    
    NSDictionary *resultDic = mod.resultDic;
    
    mod.resultCode = [NSString stringWithFormat:@"%@",resultDic[@"code"]];
    mod.resultTip = resultDic[@"message"];
    
    if (![mod.resultCode isEqualToString:@"20003"]) {
        mod.resltState = ResultFail;
        mod.resultTip  = ![StringTool isBlankString:mod.resultDic[@"message"]]?mod.resultDic[@"message"]:[StringTool isBlankString:mod.resultCode]?@"网络错误":[NSString stringWithFormat:@"网络错误%@",mod.resultCode];
    }
    
    
    return mod;
}

#pragma mark v2版的意见反馈
-(ResulteMod *)feedbacknew:(NSString *)feedBackContent mobile:(NSString *)mobile  email:(NSString *)email feedbackType:(NSString *)feedbackType{
    
    NSString *url = [API urlMake:feedback2];
//    NSString *url = [NSString stringWithFormat:@"%@%@",@"http://192.168.2.233:8203/wgf-app-distribute/",feedback2];
    NSString *consumerId = [NSString stringWithFormat:@"%zd",[UserModal shareUserModel].userId];
    NSDictionary *dict = @{@"consumerId":consumerId,@"feedBackContent":feedBackContent,@"feedbackType":feedbackType,@"mobile":mobile,@"email":email};
    
    ResulteMod *mod = [Connect doPostOutCaCheWithUrl:url withParamDic:dict];
    
    if (![mod.resultCode isEqualToString:@"20003"]) {
        mod.resltState = ResultFail;
        mod.resultTip  = ![StringTool isBlankString:mod.resultDic[@"message"]]?mod.resultDic[@"message"]:[StringTool isBlankString:mod.resultCode]?@"网络错误":[NSString stringWithFormat:@"网络错误%@",mod.resultCode];
    }
    
    
    return mod;

}
-(ResulteMod *)feedback1:(NSString *)feedBackContent
{
    NSString *url = [API urlMake:feedback];
   
    
    NSString *consumerId = [NSString stringWithFormat:@"%zd",[UserModal shareUserModel].userId];
    
    NSDictionary *dict = @{@"consumerId":consumerId,@"feedBackContent":feedBackContent};
    
    ResulteMod *mod = [Connect doPostWithOutCaCheWithUrl:url withFormdata:dict];
    
    if (![mod.resultCode isEqualToString:@"20003"]) {
        mod.resltState = ResultFail;
        mod.resultTip  = ![StringTool isBlankString:mod.resultDic[@"message"]]?mod.resultDic[@"message"]:[StringTool isBlankString:mod.resultCode]?@"网络错误":[NSString stringWithFormat:@"网络错误%@",mod.resultCode];
    }
    
    
    return mod;
}

@end
